package com.zhiming.item.service;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.zhiming.common.exception.pojo.ExceptionEnum;
import com.zhiming.common.exception.pojo.ZmException;
import com.zhiming.item.mapper.CarouselMapper;
import com.zhiming.item.pojo.Carousel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 首页轮播图 Service
 */

@Service
public class CarouselService {
    @Autowired(required = false)
    private CarouselMapper carouselMapper;

    /**
     *查询轮播图
     */
    public List<Carousel> findAll() {
        List<Carousel> carousels = carouselMapper.selectList(null);
        if(CollectionUtils.isEmpty(carousels)){
            throw new ZmException(ExceptionEnum.CAROUSEL_IMAGE_NOT_FOUND);
        }
        return carousels;

    }



}